
var is_debug = location.href.indexOf('debug=1')!=-1,
    referrer = document.referrer.toLowerCase(), url;

if(is_debug)
{
    referrer = location.href.split('referrer=')[1];
}

url = to_base;

if(!referrer)
    referrer = location.href;

for(var i=0, n = mapping.length; i < n; i++)
{
    var from = (from_base + mapping[i][0]).toLowerCase(),
        to = (to_base + mapping[i][1]).toLowerCase();

    if(referrer.indexOf(from) === 0)
    {
        url = to;
        break;
    }
}

if(is_debug)
    document.write(url);
else
    setTimeout(function(){
        window.location.href = url;
    }, 10);
